Skip to main content

This page describes the process to access any ModelPart from the global ModelPart models

Getting a ModelPart

A property of all ModelParts is that you can get a child ModelPart of a parent ModelPart by indexing the parent with the child's name.
models itself is a ModelPart. All bbmodel files in the avatar act as child ModelParts to models.
Everything in the root of a Blockbench project is a child of the bbmodel ModelPart.
After that, parenting follows the parent structure as defined in the Blockbench OUTLINER.
For example the cube RightArm,

model.bbmodel├─ Head│  ├─ Head│  └─ Head Layer└─ RightArm   ├─ RightArm   └─ RightArm Layer

Would be accessed via models.model.RightArm.RightArm

Storing a ModelPart

As there is nothing special about indexing straight from models all the time (its just another ModelPart), if a specific ModelPart is used multiple times in a script we can store it in a variable for ease of access.

--sets a World parented part to match the player's position and body rotation
local worldPart = models.model.World
function events.RENDER(delta, context)
worldPart:setPos(player:getPos(delta) * 16)
worldPart:setRot(0, -player:getBodyYaw(delta) + 180, 0)
end

BBmodels in subfolders

bbmodel files in subfolders are a special case. For them, the folder itself acts as another ModelPart.

├─ subfolderA│  ├─ Pet.bbmodel│  └─ bow.bbmodel└─ subfolderB   ├─ model.bbmodel   └─ bow.bbmodel

The bbmodel Pet.bbmodel would be accessed by models.subfolderA.Pet.